package com.th.supcom.pds.deptdispensary.server;

import java.util.ArrayList;
import java.util.List;

import net.carefx.framework.container.client.exception.UiException;
import net.carefx.framework.util.ConvertUtils;
import net.carefx.framework.web.gwt.server.GwtController;

import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
import com.extjs.gxt.ui.client.data.PagingLoadResult;
import com.th.supcom.pds.deptdispensary.client.model.DeptVsDispensaryModel;
import com.th.supcom.pds.deptdispensary.client.service.DeptVsDispensaryRpc;
import com.th.supcom.pds.domain.pojo.DeptVsDispensary;
//import com.th.supcom.ui.domain.pojo.DeptVsDispensary;
import com.th.supcom.pds.internal.api.phamapply.DeptVsDispensaryBasicService;

/**
 * DeptVsDispensary 控制层.
 * 
 * 科室与药房关系配置.
 */
public class DeptVsDispensaryServiceController extends GwtController implements DeptVsDispensaryRpc
{
    /**
     * 默认序列化
     */
    private static final long serialVersionUID = 1L;

    private DeptVsDispensaryBasicService m_deptVsDispensaryService;

    /**
     * 默认构造函数.
     */
    public DeptVsDispensaryServiceController ()
    {

    }

    public void setDeptVsDispensaryService (DeptVsDispensaryBasicService deptVsDispensaryService)
    {

        m_deptVsDispensaryService = deptVsDispensaryService;
    }

    @Override
    public DeptVsDispensaryModel getDeptVsDispensaryById (Long id) throws UiException
    {
        DeptVsDispensaryModel model = new DeptVsDispensaryModel ();
        DeptVsDispensary deptVsDispensary = m_deptVsDispensaryService.getDeptVsDispensaryByID (id);
        if (null != deptVsDispensary)
        {
            model = ConvertUtils.convert (DeptVsDispensaryModel.class, deptVsDispensary);
        }
        return model;
    }

    @Override
    public void addDeptVsDispensary (DeptVsDispensaryModel deptvsdispensaryModel) throws UiException
    {
        DeptVsDispensary deptVsDispensary = ConvertUtils.convert (DeptVsDispensary.class, deptvsdispensaryModel);
        m_deptVsDispensaryService.addDeptVsDispensary (deptVsDispensary);
    }

    @Override
    public void modifyDeptVsDispensary (DeptVsDispensaryModel deptvsdispensaryModel) throws UiException
    {
        DeptVsDispensary deptVsDispensary = ConvertUtils.convert (DeptVsDispensary.class, deptvsdispensaryModel);
        m_deptVsDispensaryService.modifyDeptVsDispensary (deptVsDispensary);
    }
    
    @Override
    public void modifyDeptVsDispensaryByDispensary(DeptVsDispensaryModel deptvsdispensaryModel) throws UiException
    {
        DeptVsDispensary deptVsDispensary = ConvertUtils.convert (DeptVsDispensary.class, deptvsdispensaryModel);
        m_deptVsDispensaryService.modifyDeptVsDispensaryByDispensary (deptVsDispensary);
    }


    @Override
    public void removeDeptVsDispensary (Long id) throws UiException
    {
        m_deptVsDispensaryService.removeDeptVsDispensaryByID (id);
    }

    @Override
    public PagingLoadResult <DeptVsDispensaryModel> getDeptVsDispensaryListWithPaging (PagingLoadConfig config)
    {

        return new BasePagingLoadResult <DeptVsDispensaryModel> (new ArrayList <DeptVsDispensaryModel> (), config.getOffset (),
                                                                 10);
    }

    @Override
    public List <DeptVsDispensaryModel> getDeptVsDispensaryByExample (DeptVsDispensaryModel model) throws UiException
    {
        List <DeptVsDispensaryModel> deptVsDispensaryModels = new ArrayList <DeptVsDispensaryModel> ();
        DeptVsDispensary deptVsDispensary = ConvertUtils.convert (DeptVsDispensary.class, model);
        List <DeptVsDispensary> deptVsDispensaries = m_deptVsDispensaryService.findDeptVsDispensaryListByExample (deptVsDispensary);
        if (deptVsDispensaries.isEmpty ())
        {
            return deptVsDispensaryModels;
        }

        return ConvertUtils.convert (DeptVsDispensaryModel.class, deptVsDispensaries);
    }

    @Override
    public List <DeptVsDispensaryModel> findDispenseTypeListByExample (DeptVsDispensaryModel model) throws UiException
    {
        List <DeptVsDispensaryModel> deptVsDispensaryModels = new ArrayList <DeptVsDispensaryModel> ();
        DeptVsDispensary deptVsDispensary = ConvertUtils.convert (DeptVsDispensary.class, model);
        List <DeptVsDispensary> deptVsDispensaries = m_deptVsDispensaryService.findDispenseTypeListByExample (deptVsDispensary);
        if (deptVsDispensaries.isEmpty ())
        {
            return deptVsDispensaryModels;
        }

        return ConvertUtils.convert (DeptVsDispensaryModel.class, deptVsDispensaries);
    }

    @Override
    public List <DeptVsDispensaryModel> findPhamMaterialTypeListByExample (DeptVsDispensaryModel model) throws UiException
    {
        List <DeptVsDispensaryModel> deptVsDispensaryModels = new ArrayList <DeptVsDispensaryModel> ();
        DeptVsDispensary deptVsDispensary = ConvertUtils.convert (DeptVsDispensary.class, model);
        List <DeptVsDispensary> deptVsDispensaries = m_deptVsDispensaryService.findPhamMaterialTypeListByExample (deptVsDispensary);
        if (deptVsDispensaries.isEmpty ())
        {
            return deptVsDispensaryModels;
        }

        return ConvertUtils.convert (DeptVsDispensaryModel.class, deptVsDispensaries);
    }

    @Override
    public void modifyDispenseTypeByExample (DeptVsDispensaryModel model) throws UiException
    {
        DeptVsDispensary deptVsDispensary = ConvertUtils.convert (DeptVsDispensary.class, model);
        m_deptVsDispensaryService.modifyDispenseTypeByExample (deptVsDispensary);
    }

    @Override
    public void addDispenseType (DeptVsDispensaryModel model) throws UiException
    {
        DeptVsDispensary deptVsDispensary = ConvertUtils.convert (DeptVsDispensary.class, model);
        m_deptVsDispensaryService.addDispenseType (deptVsDispensary);
    }

    @Override
    public void removeDispenseTypeByID (Long id) throws UiException
    {
        m_deptVsDispensaryService.removeDispenseTypeByID (id);
    }

    @Override
    public void modifyPhamMeterialTypeByExample (DeptVsDispensaryModel model) throws UiException
    {
        DeptVsDispensary deptVsDispensary = ConvertUtils.convert (DeptVsDispensary.class, model);
        m_deptVsDispensaryService.modifyPhamMeterialTypeByExample (deptVsDispensary);
    }

    @Override
    public void addPhamMeterialType (DeptVsDispensaryModel model) throws UiException
    {
        DeptVsDispensary deptVsDispensary = ConvertUtils.convert (DeptVsDispensary.class, model);
        m_deptVsDispensaryService.addPhamMeterialType (deptVsDispensary);

    }

    @Override
    public void removePhamMeterialTypeByID (Long id) throws UiException
    {
        m_deptVsDispensaryService.removePhamMeterialTypeByID (id);
    }

    /** 公司版权信息. */
    public static final String copyright = "Copyright 2014, TH Supcom Corporation";

    /** 提交路径. */
    public static final String SCC_BRANCH = "$URL$";

    /** 提交日期. */
    public static final String SCC_LAST_MODIFICATION_DATE = "$Date$";

    /** 最终修改人员. */
    public static final String SCC_LAST_MODIFIER_NAME = "$Author$";

    /** 最终版本号. */
    public static final String SCC_REVISION = "$Revision$";
}